package action.resource;

import org.apache.struts2.ServletActionContext;
import service.interf.security.IResourceType;
import action.common.MyBaseAction;

import com.opensymphony.xwork2.ModelDriven;

import dao.pojo.ResourceType;

public class ResourceTypeAction extends MyBaseAction<ResourceType> implements
		ModelDriven<ResourceType> {
	private static final long serialVersionUID = 1L;
	private IResourceType iResourceType;
	private String userName;

	/************************* setter and getter *******************************/
	public void setiResourceType(IResourceType iResourceType) {
		this.iResourceType = iResourceType;
	}

	public IResourceType getiResourceType() {
		return iResourceType;
	}
	
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public ResourceType getModel() {
		return model;
	}

	// constructor
	public ResourceTypeAction() {
		super(ResourceType.class);
		validRules.clear();
		validRules.put("resourceTypeId", "empty");
		validRules.put("resourceTypeName", "empty");
	}

	/**************************** method ***************************************/
	/**
	 * 获取所有权限
	 */
	public void findAll() {
		String r;
		try {
			r = iResourceType.findByProperty("ResourceType", "*", "json", true, null,
					null, null, null,model.getPage(),model.getRows());
		} catch (Exception e) {
			r = errorHandle.handleErr(e);
		}
		servletHandle.writeToClient(ServletActionContext.getResponse(), r);
	}

}
